package com.itheima02;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test05 {
    public static void main(String[] args) {
        Collection<String> s = new ArrayList<>();
        s.add("Java 企业级开发指南");
        s.add("Oracle 高级编程");
        s.add("MySQL 从开发到精通");
        s.add("Java 架构师之路");

        Iterator<String> iter = s.iterator();
        while (iter.hasNext()) {
            String next = iter.next();
            System.out.println(next);
        }
        Collection<String> s1 = new ArrayList<>();
        s1.add("Java企业级开发指南");
        s1.add("Oracle高级编程");
        s1.add("MySQL从开发到精通");
        s1.add("Java架构师之路");
        Iterator<String> iter1 = s1.iterator();
        while (iter1.hasNext()) {
            String next1 = iter1.next();
            if (next1.length() < 10) {
                System.out.println(next1);
            }
        }
        Collection<String> s2 = new ArrayList<>();
        s2.add("Java企业级开发指南");
        s2.add("Oracle高级编程");
        s2.add("MySQL从开发到精通");
        s2.add("Java架构师之路");
        Iterator<String> iter2 = s2.iterator();
        while (iter2.hasNext()) {
            String next2 = iter2.next();
            if (next2.contains("Java")) {
                System.out.println(next2);
            }

        }

        System.out.println("-----------------");
        Collection<String> s3 = new ArrayList<>();
        s3.add("Java企业级开发指南");
        s3.add("Oracle高级编程");
        s3.add("MySQL从开发到精通");
        s3.add("Java架构师之路");
        Iterator<String> iter3 = s3.iterator();
        while (iter3.hasNext()) {
            String next3 =  iter3.next();


        }

        s3.removeIf(
                (String a) -> {
                    return a.contains("Oracle");
                }
        );
        for (int i = 0; i < s3.size(); i++) {
            System.out.println(((ArrayList<String>) s3).get(i));
        }

    }
}



